<template>
  <div class="header-info">
    <span class="name-company">
      <span class="name" v-if="[1].indexOf(parseInt($store.state.userInfo.role))!==-1">{{$store.state.companyInfo.companyName}}</span>
    </span>
    <div class="tool tool-user">
      <span class="user-card">
        <div class="styled-icon-user pic">
          {{$store.state.userInfo.name}}
        </div>
        <i class="fa fa-chevron-down t-small"></i>
      </span>
      <ul class="user-nav">
        <!-- <li @click="projectSpeed.open=true">
            <i class="iconfont icon-personal"></i>
            <span>切换项目</span>
        </li> -->
          <li @click="logout">
              <i class="iconfont icon-quit"></i>
              <span>退出</span>
          </li>
      </ul>
    </div>
    <i-modal :msg="errorModal.msg" v-if="errorModal.open" @confirm="closeError" @cancel="closeError"/>
  </div>
</template>


<script>
import Store from '@/common/store/store.js';
export default {
  name: 'header-info',
  components: {
  },
  mounted () {
  },
  data () {
    return {
      projectSpeed: {
        open: false
      },
      projectSel: '',
      errorModal: {
        open: false,
        msg: ''
      }
    };
  },
  watch: {
    listenErrorMsg: function () {
      if (Store.state.errorMsg) {
        this.errorModal.open = Store.state.errorMsg.open;
        this.errorModal.msg = Store.state.errorMsg.msg;
      }
    }
  },
  computed: {
    listenErrorMsg () {
      return Store.state.errorMsg;
    }
  },
  methods: {
    closeProjectTem () {
      this.projectSpeed.open = false;
    },
    closeError () {
      Store.commit('setErrorMsg', {
          open: false,
          msg: ''
        });
    },
    logout () {
      location.href = '/sharespot-server/public/logout';
    }
  }
};
</script>

<style lang="less" scoped>
.header-info {
  height: 50px;
  line-height: 50px;
  background-color: #ffffff;
  border-bottom: 1px solid #dcdcdc;
  .name-company{
    float: left;
    font-size: 16px;
    color: #FFFFFF;
    font-weight: bolder;
    height: 50px;
    .name{
      vertical-align: 23px;
      color: #FE6C3B;
      margin-left: 30px;
    }
  }
  .tool-user {
    padding: 0;
    margin-left: 0;
    vertical-align: top;
    color: #606266;
    float: right;
    .user-card {
      text-align: center;
      width: 90px;
      padding: 0 14px;
      display: inline-block;
      height: 40px;
      .pic{    
        line-height: 40px;
      }
    }
    .user-nav {
      display: none;
      background-color: #fff;
      text-align: center;
      z-index: 1;
      color: #eee;
      border-bottom-left-radius: 4px;
      border-bottom-right-radius: 4px;
      text-align: center;
      position: absolute;
      color: #9099fe;
      right: 3px;
      width: 100px;
      box-shadow: 0 0 10px #666;
      padding: 10px 0;
      li{
        line-height: 35px;
        height: 35px;
        color: #333;
        cursor: pointer;
        &:hover{
          color: red;
        }
      }
      a{
        color: #333;
        &:hover{
          color: #606266;
        }
      }
    }
    &:hover{
      .user-nav {
        display: block;
      }
    }
  }
  .project-tempalte{
    .content{
      padding: 20px 0 15px;
      text-align: center;
      >div{
        margin-bottom: 15px;
        span{
          width: 60px;
          display: inline-block;
          font-size: 14px;
          color: #666;
        }
        input{
          width: 250px;
          height: 33px;
        }
      }
    }
    .foot-it{
      height: 60px;
      .btn-it{
        
      }
    }
  }
}
</style>

